home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / NLB_FADE.ZIP / FADE.ASM next >
Assembly Source File  |  1995-06-07  |  4KB  |  120 lines

  1.  
  2. ;
  3. ; A simple Fade-in and Fade-out routine.
  4. ;
  5.  
  6. ideal
  7. p386n
  8.  
  9. segment code
  10. assume cs:code
  11. org 100h
  12.  
  13. start:
  14.                 mov     ax,13h                  ; Guess
  15.                 int     10h
  16.                 call    write_palette           ; Call
  17.                 push    0a000h                  ; Destenation now is VgaSeg.
  18.                 pop     es
  19.                 lea     si,[picture]            ; write picture to VgaSeg.
  20.                 mov     di,46*320
  21.                 mov     cx,107*80
  22.                 rep     movsd
  23.  
  24.                 mov     bp,63                   ; fade in loop
  25. fade_in_loop:   mov     cx,4
  26.                 call    vwait
  27.                 call    fade_in
  28.                 call    write_palette
  29.                 dec     bp
  30.                 jnz     fade_in_loop
  31.  
  32.                 xor     ax,ax                   ; wait for a key press
  33.                 int     16h
  34.  
  35.                 mov     bp,63                   ; fade out loop
  36. fade_out_loop:  mov     cx,4
  37.                 call    vwait
  38.                 call    fade_out
  39.                 call    write_palette
  40.                 dec     bp
  41.                 jnz     fade_out_loop
  42.  
  43.                 mov     ax,3                    ; texmode reset
  44.                 int     10h
  45.                 mov     ah,9                    ; drop ending text
  46.                 lea     dx,[endline]
  47.                 int     21h
  48.                 mov     ax,4c00h                ; return to operating system
  49.                 int     21h
  50.  
  51.         ;
  52.         ; ------------------------------
  53.         ;
  54.  
  55. proc            fade_in                         ; fade in palette
  56.                 xor     bx,bx
  57. @@full_fade:    mov     al,[palette+bx]
  58.                 cmp     [pal_buf+bx],al
  59.                 je      no_inc
  60.                 inc     [pal_buf+bx]
  61. no_inc:         inc     bx
  62.                 cmp     bx,768
  63.                 jne     @@full_fade
  64.                 ret
  65. endp            fade_in
  66.  
  67. proc            fade_out                        ; fade out palette
  68.                 xor     bx,bx
  69. @@full_fade:    cmp     [pal_buf+bx],0
  70.                 je      no_dec
  71.                 dec     [pal_buf+bx]
  72. no_dec:         inc     bx
  73.                 cmp     bx,768
  74.                 jne     @@full_fade
  75.                 ret
  76. endp            fade_out
  77.  
  78. proc            write_palette                   ; Write palette to port
  79.                 mov     dx,3c8h                 ; Writes the buffer,
  80.                 lea     si,[pal_buf]            ; not the palette!
  81.                 mov     cx,768                  ; the buffer is for the
  82.                 xor     al,al                   ; compare loop with fade in.
  83.                 out     dx,al
  84.                 inc     dx
  85.                 rep     outsb
  86.                 ret
  87. endp            write_palette
  88.  
  89. proc            vwait                           ; Vertical Wait
  90.                 mov     dx,3dah
  91. v1:             in      al,dx
  92.                 test    al,8
  93.                 jne     $-3
  94.                 in      al,dx
  95.                 test    al,8
  96.                 je      $-3
  97.                 loop    v1
  98.                 ret
  99. endp            vwait
  100.  
  101.         ;
  102.         ; ------------------------------
  103.         ;
  104.  
  105.   include       "picpal.db"
  106.  
  107.   endline       db 'Graphics by PiNO / GROUND ZERO!',13,10
  108.                 db 'Please don''t use this picture for own use!',13,10
  109.                 db 'because it isn''t finished and shit',13,10
  110.                 db 'whoever uses this piece of un-finished art',13,10
  111.                 db 'will be punished within 24 hours...',13,10
  112.                 db 'A warned lamer counts for 2 :)',13,10
  113.                 db 24h
  114.  
  115.   pal_buf       db 768 dup (0)                  ; total blackness 4 fade in
  116.  
  117. ends code
  118. end start
  119.  
  120.